package com.xhx.spring.service;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @program: xh-learn-record
 * @description:
 * @author: sch
 * @create: 2023-03-03 17:08
 **/
@Service
public class BeanLifeService implements BeanNameAware, DisposableBean, InitializingBean {
    @Autowired
    private OrderService orderService;

    public BeanLifeService() {
        System.out.println("自身BeanLifeService的构造函数...1");

    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterSet 初始化方法...5");
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("bean aware 回调...3");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("destroy... 7");
    }

    @PostConstruct
    public void postConstruct() {
        System.out.println("beanlifeservice postConstruct...5");
    }


    public void initMethod() {
        System.out.println("BeanLifeService initMethod...5");
    }

    public void destroyMethod() {
        System.out.println("BeanLifeService destroyMethod...8");
    }

}
